package com.zby.controller.article;

import com.zby.common.utils.ResultUtil;
import com.zby.model.pojo.Comment;
import com.zby.model.vo.CommentVo;
import com.zby.service.imp.CommentServiceImp;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "评论管理")
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentServiceImp commentServiceImp;


    //插入评论功能
    @PostMapping("/insertComment")
    @Schema(description = "插入评论功能")
    public ResultUtil<Comment> addComment( @RequestBody Comment comment){
    //要为前端返回评论id,姓名，头像，评论内容，评论时间，评论文章id，评论用户id，父评论id，评论点赞数，评论状态，评论删除状态
       commentServiceImp.inertComment(comment);
        return ResultUtil.success();
    }
    //查询所有评论功能
    @GetMapping("/selectComment")
    @Schema(description = "查询某id评论功能")
    public ResultUtil<List<CommentVo>> selectComment(@RequestParam Integer id){

        List<CommentVo> comments = commentServiceImp.selectComment(id);
        return ResultUtil.success(comments);
    }

}
